In [1]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys
from cStringIO import StringIO

import numpy as np
import requests

if 'saga_base_dir' not in locals():
    saga_base_dir = os.path.abspath('..')
if saga_base_dir not in sys.path:
    os.chdir(saga_base_dir)

In [2]:
for module in ['hosts', 'targeting', 'mmthecto']:
    if module in globals():
        reload(globals()[module])
    else:
        globals()[module] = __import__(module)
g = targeting.get_gama() #re-caches the gama catalo

In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

In [4]:
from astropy import units as u

from astropy.table import Table
from astropy import table
from astropy.coordinates import SkyCoord

In [5]:
# this version includes those both with *and* without incomplete data
mltab = Table.read('catalogs/SAGA.objid.noclean.PROBS_WISE_PROBS.sept28.fits.gz')
mltab


Out[5]:
<Table masked=True length=1689331>
OBJID_1RADECDERED_RPROBABILITY_CLASS_1BEST_GUESS_CLASSOBJID_2PROBABILITY_CLASS_WISE_1BEST_GUESS_CLASS_WISE
int64float64float64float64float64int64int64float64int64
123764594182435644040.2877964113-0.73564706094916.75940.00157168316197012376459418243564400.002375421849740
123764594182435644240.2745834514-0.73301406347817.45140.000372493836691012376459418243564420.0001500148285250
123764594182435648140.2721052363-0.64251025320416.79110.00178514575454012376459418243564810.001188685123230
123764594182435648340.2712777717-0.64072529300120.98940.0002404548112860--nan--
123764594182435649740.2846730128-0.81718021579914.86280.000363130559728012376459418243564970.0007627386591670
123764594182435650040.2881452154-0.80504550894814.38260.000488674982738012376459418243565000.0005415633422480
123764594182435650140.2854134086-0.80410047343220.24540.0007633014669820--nan--
123764594182435654640.2730041845-0.65237448207517.24350.000137542029002012376459418243565469.49131806038e-050
123764594182435659740.287315948-0.76789783904619.89690.000115278704656012376459418243565974.28634811895e-050
123764594182435666840.2778355788-0.77707411228719.740.000276325061678012376459418243566680.0004646500764660
...........................
12376802972817169621.4465672193621.640283521320.31930.0008658292303710--nan--
12376802972817170281.4764859772121.638590841920.13990.000235568236113012376802972817170280.0001021968117750
12376802972817170371.4782557947521.642472941920.7290.000220338930026012376802972817170370.0001312652657090
12376802972817170471.4846218417921.624873206519.57137.1485843043e-05012376802972817170470.0002808103765980
12376802972817170511.4859185470321.631398802220.1429.38192218398e-05012376802972817170513.97546613939e-050
12376802972817170631.4910504257821.637387889919.95710.000571262753599012376802972817170630.0003684925076580
12376802972817170671.4928499812521.633423791720.24813.32460659433e-05012376802972817170674.1368325854e-050
12376802972817171501.3864150595821.647592807420.53070.0001238460717210--nan--
12376802972817819001.4985220800521.631728324318.11390.000565032531386012376802972817819000.001294573812890
12376802972817822271.5043843701621.626287124120.44810.0002287081377540--nan--

In [6]:
allspec = Table.read(os.environ['HOME']+'/Dropbox/SAGA/data/allspectaken_v4.fits')
allsats = allspec[(allspec['SATS']==1)&(allspec['REMOVE']==-1)]
allsats


Out[6]:
<Table masked=True length=121>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDPCLASS_1SATSREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEAT
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string384float64float64int64int64int64int64string32string384float64string384
1237648702984683605225.005401226-1.0913022673431161121054724696103817046451974348816.025115.327415.008714.900314.78380.007903070.002745120.003204070.004456610.009042040.3277120.2411280.1748860.1326110.094022617.932218.7455-99.0-99.06.3540215.5154-99.020.98090153516.0790.214.2869999.014.0229999.012.57170.0040470613.4520.0310.006297655.12096e-0600.0524630.042043224.594-1.0910228.40381922.07.693145729024.6830184051203.93750357835574-11-1NSAsdss4.0SDSS
1237650372092690464180.29544216-1.297683831931319448581640280014.718913.868913.523313.364313.31120.006161120.002182750.002218780.002977850.005712360.187590.1380270.1001090.07590930.053820718.121518.8384-99.0-99.016.260736.7104-99.021.392664250716.4810.20314.6879999.014.3539999.013.570.03213.4150.0420.00496344-1.000.039220.037245180.098-1.1000823.24871465.07.3211405940Alice16.7329983482113.161017531171514-11-1NSAsixdf4.0
1237662524159557759195.10391847613.67025281173263951778713872199399133369338470416.294115.390915.071114.953214.93470.02273120.006675440.01175050.01818980.02993570.1823220.1341510.09729740.07377770.052309319.502920.3731-99.0-99.011.788731.5461-99.022.14881316299999.09999.09999.09999.09999.09999.014.9310.0414.6620.0710.006701541.43393e-0500.029640.021994194.86314.171230.0271988.07.907142722033.1822246225289.82564855875784-11-1NSAsdss4.0SDSS
1237662525233037420194.57210413614.557151882331161189774200920199402266977477632015.079413.905713.342213.064612.84580.008764890.002582330.002530720.002780830.007909940.1384850.1018960.07390360.05603890.039732318.035618.8593-99.0-99.022.410763.5675-99.021.839335819415.6880.13815.0750.16614.5430.12510.9780.0016625613.4650.0620.006742941.85704e-0500.0449880.01468194.86314.171230.0271988.07.907142722028.678557215250.4899595169964-11-1NSAsdss4.0SDSS
1237662196143947955206.06203055641.6773969113335253360136464155047609820095488017.570316.362615.722915.442215.40750.03577360.005511780.004911730.00561550.01569720.03721170.027380.01985830.01505790.010676318.742519.4958-99.0-99.06.8654123.2344-99.021.81763763416.6260.12915.8180.13115.6830.18913.87420.0075292214.7490.050.008695959.33515e-0600.0555040.026538206.3341.712537.22852549.018.434163956012.1863238779131.969466856424-11-1NSAsdss4.0SDSS
1237662307796910232206.1906667341.55671773475058011246640155048654356141875218.25517.093816.544216.292416.10360.03688740.006376970.005904590.008112270.02740150.04391430.03231180.02343520.01777020.012599319.29820.0954-99.0-99.05.5703913.9169-99.022.195783279999.09999.09999.09999.09999.09999.014.22030.01095615.0780.0610.008945332.04436e-0500.0485050.029693206.3341.712537.22852549.018.434163956011.2416329592121.73915493356427-11-1NSAsdss4.0SDSS
1237662300829384713228.77161386842.209456892631178711093284952188934421391765708816.705214.232513.189512.607912.06450.01794650.002381260.001940240.001803910.002342640.1306450.0961270.06971930.0528660.037482716.682917.459716.748521.624577111213.253935.588413.325220.932335877212.2569999.011.6440.0610.7219999.010.2090.0001287569.450.020.008326389.01325e-0600.0765110.029508228.76442.049936.91722562.08.573166035544Hamlet9.57904047243102.86705766869290--1-1NSAsdss4.0SDSS
1237655369832267945217.9453357558.0087096127319361739427439288958081253247590416.907115.857615.394415.186115.0470.02229660.004480640.004447440.005790070.01810760.05459570.0401710.02913540.02209250.015663819.116519.9402-99.0-99.015.784153.7135-99.022.21076086689999.09999.09999.09999.09999.09999.013.43550.006239514.8550.0550.00611507-1.000.0324180.014835218.02357.921531.00851898.398.27716515305.7811975526552.146417920928287-11-1NSAsdss4.0
1237664871897039021141.02204138234.64656417533105624251797848143442154545482342418.000716.334515.69215.379715.15780.04866390.007944830.007020560.008336430.02079710.08810580.06482740.04701830.03565250.025278119.544920.382710.225922.73590061858.7856717.843415.749522.46386046289999.09999.09999.09999.09999.09999.014.8830.0414.8640.0850.006234495.27589e-0500.0612310.029378141.07734.513527.67141687.08.03213587908.4335440226967.8839226826-1-11-1SDSSSDSS4.0SDSS
1237664871897170083141.50622822734.65340218543263988285935704179364958636817817615.662314.506813.968713.699513.53530.01212580.004680730.004141630.005070040.01333350.111620.08212890.05956670.04516770.032024418.541519.3918-99.0-99.017.297645.7608-99.021.97921385159999.09999.09999.09999.09999.09999.011.57330.0029440713.6210.0390.005394661.66289e-0500.0346370.029037141.07734.513527.67141687.08.032135879022.813830591183.63365315564909-11-1NSAsdss4.0SDSS
..........................................................................................................................................................................................
1237664669514662021171.1162007939.8140845353105622104313872224742821309975142417.896417.04316.630816.445416.40850.03463910.009764110.01049250.01793960.03463720.1215410.08942910.06486140.04918240.03487119.871220.702-99.0-99.010.043336.8172-99.022.68643522689999.09999.09999.09999.09999.09999.014.63530.019245415.690.1180.006255871.99016e-0500.0506680.047781170.63139.876931.56291948.09.453139281022.6523061801207.97555740788021-11-1NSAsdss4.0SDSS
1237662226210160806170.45777186840.0018120793176027355713880224739412823929036818.859718.030417.525317.336317.4390.0892170.0222890.01609510.01829160.06915650.1091120.08028340.05822820.04415270.031304820.453521.2731-99.0-99.07.1237822.3917-99.023.11265464589999.09999.09999.09999.09999.09999.015.45060.03604116.3250.2420.00664252.15579e-0500.1564020.061138170.63139.876931.56291948.09.453139281010.9454692896100.49319859488016-11-1NSAsdss4.0SDSS
1237664670051336378170.40248254540.15599467113193583034535952222945697037132800017.317216.161515.675315.425715.360.0334210.006798190.005608480.01017120.03223790.09348880.06878810.04989090.03783080.026822519.308920.1369-99.0-99.09.3767523.2929-99.022.35209714229999.09999.09999.09999.09999.09999.013.50910.010027114.9180.0880.006446683.40538e-0500.0334670.020791170.63139.876931.56291948.09.453139281019.7806207768181.61032562486968-11-1NSAsdss4.0SDSS
1237664669514596560170.77894501839.95672810333105624251797520224740512335556812818.079517.185616.809916.642716.51050.02714950.01098250.01236720.02198880.1117340.09874890.07265850.0526980.03995930.028331619.655620.4609-99.0-99.06.4640517.0031-99.022.51435906889999.09999.09999.09999.09999.09999.014.61990.01849915.3270.0950.006491397.35389e-0600.0403960.033603170.63139.876931.56291948.09.45313928108.3295964067176.476244094988018-11-1NSAsdss4.0SDSS
1237660765378248765137.96215550634.9637406847335253361184784143339954936325120016.232415.461315.080314.873714.70510.02894380.006739930.007166490.007870710.02563490.1135950.08358190.06062060.04596670.03259119.798520.6367-99.0-99.017.464343.3808-99.023.03198096379999.09999.09999.09999.09999.09999.015.3580.04815.1040.1060.006909491.26599e-0500.0421440.037786138.10235.027532.33742049.09.50613573907.8686013137974.0164715186157086-11-1NSAsdss4.0SDSS
1237660765378314404138.18497416634.925549611431161153266978832143340339765394841615.293214.005613.348513.021712.8090.006612280.002194610.002017640.00208950.003141180.1223390.09001580.06528690.04950510.035099717.654418.4177-99.0-99.012.772124.1065-99.020.889550121115.0160.08314.3010.08813.9610.08210.41280.00092850712.20.0250.006519129.36948e-0600.0922290.036795138.10235.027532.33742049.09.50613573907.3478491069469.117992287850569-11-1NSAsdss4.0SDSS
1237660765915316352138.04093028335.53761471623105624251797848136459348122117120018.376917.141116.904116.92718.41680.07024250.01008810.01303620.02064290.29220.11150.08204040.05950250.0451190.031989920.264120.949515.876524.90330402528.7289115.552917.167423.86767072689999.09999.09999.09999.09999.09999.09999.09999.09999.09999.00.006364233.27313e-0600.0750010.115918138.10235.027532.33742049.09.506135739030.7536074138289.28205192-1-11-1SDSSSDSS4.0SDSS
1237667255616143515158.0432463428.4830569538335253360136208265039070955466956816.97715.7915.267215.029514.89580.01560950.003085090.003230440.003623450.00773560.1267240.0932420.06762690.05127940.036357717.864718.619-99.0-99.05.7980715.8747-99.021.050925563215.7580.0915.3220.1215.0770.12712.85760.0050885313.7880.0440.005276561.02568e-0500.0512280.027819158.23128.511824.41171408.08.917137625010.047496908271.3479343973107759-11-1NSAsdss4.0SDSS
1237667287812735027157.77827429828.7966447953335253360136208265040170467094732814.709913.63812.997312.777512.49020.004155980.001790260.001726870.001747060.002232480.1236420.09097450.06598230.05003240.035473615.541216.2389-99.0-99.06.0696816.2422-99.019.090724709612.7890.04712.1360.04811.9530.0499.987360.0003462710.4910.0210.00474537.54079e-0600.1115930.043889158.23128.511824.41171408.08.917137625029.360597066208.489287227107764-11-1NSAsdss4.0SDSS
1237665367429677221158.71239779828.66385332883263953926197264265271260301652172817.087115.986915.574815.370715.31780.04032340.005897110.007747270.0103460.05432780.1541840.1134470.08228150.06239160.044236419.386220.2372-99.0-99.09.9859929.4525-99.022.13534598949999.09999.09999.09999.09999.09999.014.8230.03914.6350.0740.004413112.32353e-0500.0416550.02169158.23128.511824.41171408.08.917137625026.9982990593191.714994189107942-11-1NSAsdss4.0SDSS

In [7]:
# info on all the hosts to decide which to investigate further
nsaid2name = {}
for row in allsats:
    nsaid2name[row['HOST_NSAID']] = row['HOST_SAGA_NAME']
    
Table(rows=[(i, 
         nsaid2name[i], 
         np.sum(allsats['HOST_NSAID']==i), 
         np.sum((allsats['HOST_NSAID']==i)&(allsats['MASKNAME']!='sdss')))
        for i in np.unique(allsats['HOST_NSAID'])],
      names=['NSAID', 'host name', 'n_sats', 'n_sats_not_sdss']).pprint(max_lines=1000)


NSAID  host name n_sats n_sats_not_sdss
------ --------- ------ ---------------
    32                1               0
 16235                3               0
 16559                2               0
 33446  StarTrek      2               0
 61945      AnaK      2               0
 69028                3               1
 85746  MobyDick      1               1
 94217                1               0
135129                5               0
135440                1               0
135667   Beowulf      8               4
135739                3               1
135879                5               2
137625                3               0
138201                5               0
138375                3               1
138642                2               0
139281                4               0
140065                3               1
140301                2               1
140458                1               0
140594     Alice      1               1
141465                1               0
142722                2               0
143856                1               0
144953                3               0
145297                1               0
145398                1               0
145729                1               0
147100   Odyssey      8               7
147606                2               0
148734    Aeneid      2               2
149781  OBrother      2               2
150238     Iliad      1               1
150340   Ulysses      1               0
157374                3               0
158541                1               0
159593                1               0
161174                1               0
162580                4               1
163136                2               0
163956                2               0
164995                3               0
165082                5               0
165153                1               0
165316                4               1
165536      Dune      2               1
165707                1               0
166035    Hamlet      1               0
166313 Gilgamesh      3               2

Odyssey it is, then...


In [26]:
ody = hosts.odyssey

In [12]:
odycat = Table.read('catalogs/base_sql_nsa147100.fits.gz')
odycat


Out[12]:
<Table masked=False length=116533>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDSATSREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEAT
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string376float64float64int64int64int64string32string376float64string376
1237662698115433791248.11877751219.80048292213422281453109248024.706824.295422.839121.942921.70090.6977230.3922430.1705790.1218570.2941420.3204070.2357530.1709870.1296550.091926723.299223.64640.29404422.1768475140.4554960.70309823.247923.53578020989999.09999.09999.09999.09999.09999.019.07870.5675879999.09999.0-1.0-1.0-10.5484460.069731248.08719.826434.31992375.08.651471000Odyssey2.3738622436423.698868408-1-1-1-1.0
1237662698115433225248.12295655819.84698244368987912704023.051322.373221.572321.399820.92630.3650240.09977110.06729250.0899480.1895540.324720.2389260.1732890.13140.093164121.966622.49280.44051521.78746163830.6644051.3908421.631322.7389495269999.09999.09999.09999.09999.09999.019.62340.947749999.09999.0-1.0-1.0-10.3215520.039179248.08719.826434.31992375.08.651471000Odyssey2.3757137854823.7173528165-1-1-1-1.0
1237662698115433190248.06949653819.7887422658335253360132880024.567525.063822.786321.609720.4340.8207110.5863610.1954180.1080850.1268040.3193350.2349640.1704150.1292210.091619123.032323.54220.42989423.06942819120.5523221.6374222.983723.69013964259999.09999.09999.09999.09999.09999.018.01410.2090779999.09999.0-1.0-1.0-10.7944590.103854248.08719.826434.31992375.08.651471000Odyssey2.4660160702424.6188632595-1-1-1-1.0
1237662698115433217248.07644520519.7864371366368987912960019.417419.217917.168216.92616.27330.5739690.2143280.04901370.06359360.1155490.3189340.2346690.1702010.1290580.09150422.634523.212959.350828.030816319675.3133130.95316.095227.4750530119999.09999.09999.09999.09999.09999.019.40310.760889999.09999.0-1.0-1.0-10.3908980.113254248.08719.826434.31992375.08.651471000Odyssey2.4706733683624.6653582387-1-1-1-1.0
1237662698115433272248.13056263719.8317867144635253393686800024.904623.608921.902521.42721.13170.6049750.2269840.0717940.07288010.1765770.3235390.2380570.1726580.1309220.092825122.271822.73780.0006776268.052956224090.3987540.814922.162822.16182549989999.09999.09999.09999.09999.09999.018.06410.232129999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey2.4799775106524.7582438325-1-1-1-1.0
1237662698115433729248.06585546119.79108452643281640601387776019.892820.220218.52718.161417.34950.4220430.2642670.08103540.09432390.1476650.3194580.2350540.1704810.129270.091654322.904823.45040.62458323.43146319940.6608981.9229422.455923.55205589399999.09999.09999.09999.09999.09999.017.88530.1853229999.09999.0-1.0-1.0-10.497160.124777248.08719.826434.31992375.08.651471000Odyssey2.4319192606924.2784662276-1-1-1-1.0
1237662698115433063248.11185985619.79067707586281543964623104022.622525.135324.048823.049322.76980.2180830.4544960.3654210.2665570.4063680.3189280.2346640.1701980.1290560.091502423.993924.329259.340127.87218277770.6158471.3875823.823324.76607865749999.09999.09999.09999.09999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey2.5618280925325.5753787808-1-1-1-1.0
1237662698115433191248.06866318519.7882256128335253360132880020.598419.347618.414918.019817.6790.7816930.1161570.07148680.08088970.194580.3192120.2348730.170350.1291710.091583922.316722.87140.49130622.49870264930.9967443.0935721.693823.68219839129999.09999.09999.09999.09999.09999.018.63650.3842029999.09999.0-1.0-1.0-10.1869490.042753248.08719.826434.31992375.08.651471000Odyssey2.5134505029225.0924131361-1-1-1-1.0
1237662698115433215248.12179965819.852698119368987912192023.128522.777521.919521.295821.30070.3452020.1229260.07717650.07047620.2146320.3253050.2393570.1736010.1316370.09333222.267322.78530.25268120.92776593060.5286211.3429921.980222.59141020339999.09999.09999.09999.09999.09999.017.56880.1424549999.09999.0-1.0-1.0-10.4742610.165486248.08719.826434.31992375.08.651471000Odyssey2.5194965854125.1527726986-1-1-1-1.0
1237662698115433282248.10057578319.78739357063105622104310544019.582719.994117.021516.318216.07710.7952420.5529640.05277110.04517730.1180180.3185460.2343830.1699940.1289020.091392822.814923.414259.355627.88427467863.166915.330120.958625.45718225459999.09999.09999.09999.09999.09999.017.48050.1261519999.09999.0-1.0-1.0-10.3354280.135171248.08719.826434.31992375.08.651471000Odyssey2.4626340720424.5850999203-1-1-1-1.0
.......................................................................................................................................................................................
1237662225166370117248.99019316520.31820599116158398662443264023.628821.349520.032319.139818.5520.4496890.03477140.01871910.01370860.02984450.4311650.3172470.2300940.1744730.12370420.37720.86950.079338716.52520421130.455071.037720.122620.40848760789999.09999.09999.09999.09999.09999.016.35230.048150216.4349999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey58.9036377743588.021217599-1-1-1-1.0
1237662225166369828248.95959291320.393809806368987912448025.859322.510120.791820.26419.83440.7503940.1608760.05779270.05367070.1603030.4190910.3083630.2236510.1695880.1202421.621922.2210.79441422.56754757270.9216752.6352920.993122.81146715589999.09999.09999.09999.09999.09999.016.61070.061970516.4570.312-1.0-1.0-10.3108440.029026248.08719.826434.31992375.08.651471000Odyssey59.87329036597.700061392-1-1-1-1.0
1237662225166435969249.06339377620.21526719693281543964623616024.048325.697222.862422.007521.62880.6498760.3954150.1786790.1294840.3908310.3945640.2903160.2105620.1596620.11320323.160923.63640.21498221.58804565420.5595121.6302822.702623.43706153119999.09999.09999.09999.09999.09999.016.34040.045105916.8320.428-1.0-1.0-10.4570130.147432248.08719.826434.31992375.08.651471000Odyssey59.8465741103597.433386712-1-1-1-1.0
1237662225166435433249.04716451920.210064287332450547278080025.902622.492821.494820.554320.9890.8290310.1737480.1185330.07878250.4957870.3975160.2924880.2121370.1608570.1140522.36322.94190.65831122.9343169811.111392.5267321.677423.90215805399999.09999.09999.09999.09999.09999.016.51430.054797516.2830.248-1.0-1.0-10.3064990.188134248.08719.826434.31992375.08.651471000Odyssey58.8813576748587.798822339-1-1-1-1.0
1237662225166369177248.95074042620.3764197577672057663025975296020.555618.961618.278318.042617.92630.0507460.008752050.008021260.00849490.01974980.4290560.3156950.2289690.173620.12309918.628319.12210.087504714.98526109970.4712571.0303418.37118.73269788449999.09999.09999.09999.09999.09999.016.53880.057036716.7529999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey58.8717726626587.703146759-1-1-1-1.0
1237662225166369834248.9611186520.3912783233335255507485456021.694421.003119.99419.663619.41360.2187890.05110280.03833740.03907710.1354620.419730.3088340.2239920.1698460.12042320.926521.61171.4331422.77092518741.389632.9135920.016422.72630209469999.09999.09999.09999.09999.09999.016.66570.071812816.8870.48-1.0-1.0-10.3503410.05479248.08719.826434.31992375.08.651471000Odyssey59.8580185026597.547621675-1-1-1-1.0
1237662225166436137249.04158242620.26710176853387099228373776025.455125.410823.040122.054321.1440.5585870.4571070.2145490.1424860.284520.4164230.30640.2222270.1685080.11947423.367323.7920.23378721.99069136860.4809771.3145923.094423.50046001519999.09999.09999.09999.09999.09999.016.86780.073934216.9180.435-1.0-1.0-10.6611680.084363248.08719.826434.31992375.08.651471000Odyssey60.0186133985599.150637666-1-1-1-1.0
1237662225166369739248.94740095520.4144193816668987912448025.235422.655521.254719.900319.1480.5440550.09581330.04411630.02224270.04740540.417140.3069270.2226090.1687980.1196821.586122.07970.04682316.61644317540.4779421.3629121.243721.63600997049999.09999.09999.09999.09999.09999.016.67710.06484916.6459999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey60.0268648799599.233001747-1-1-1-1.0
1237662225166435295249.04343211120.2536057608668987912448023.208323.297221.991220.343719.370.3930050.1815270.0884920.03400780.06259950.4143810.3048980.2211370.1676820.11888822.365622.88380.16646720.23444314040.5424031.4017122.033322.70034492039999.09999.09999.09999.09999.09999.016.82130.071818116.8370.411-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.7605843213596.57505868-1-1-1-1.0
1237662225166369213248.96139871720.3623116758335253360136208022.984921.505120.796820.573919.99790.4995440.05999250.05640060.06758140.1670790.4325290.318250.2308220.1750250.12409521.438622.06011.1373323.07170029010.9403771.6809420.945722.80770020889999.09999.09999.09999.09999.09999.018.01110.24349516.7889999.0-1.0-1.0-10.1251590.069347248.08719.826434.31992375.08.651471000Odyssey58.9046025134588.030847421-1-1-1-1.0

In [15]:
odysats = allsats[allsats['HOST_NSAID']==147100]
odysats


Out[15]:
<Table masked=True length=8>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDPCLASS_1SATSREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEAT
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string384float64float64int64int64int64int64string32string384float64string384
1237662662147571761248.39322569719.9461400824335221147877392186793451999516467217.235316.289715.819615.659315.4610.01380570.003517460.00325810.003809210.009156280.3374880.2483210.1801030.1365660.096827317.560918.279-99.0-99.03.013748.61439-99.020.148803944215.6980.12815.0750.15314.7520.11913.07430.0036805713.3550.0330.008048235.23156e-0600.0230840.01586248.08719.826434.31992375.08.651471000Odyssey18.7177808521186.86344163268553-11-1NSAsdss4.0SDSS
1237662224092364842247.87738757320.09362484073105622104314128208758973604982988818.421117.492317.17516.961417.21410.06120940.01239690.01466030.02033130.08854590.3349590.2464590.1787530.1355430.096101620.93121.680915.982425.18869639888.2506315.049417.379623.95753037489999.09999.09999.09999.09999.09999.015.42250.069000416.3880.2560.008264266.53467e-0600.0799610.09424248.08719.826434.31992375.08.651471000Odyssey19.926148232198.926689786-1-11-1SDSSSDSS4.0SDSS
1237662698115432783248.15207968619.810259136633525550762011227719.054618.146517.791417.477517.40550.07730640.01533580.03245490.04473020.04958810.3215380.2365850.1715910.1301120.092251320.644921.42258.215924.36011943235.001329.5464417.956523.44742148269999.09999.09999.09999.09999.09999.015.61680.04780416.8439999.00.007628-1.0-10.0907680.024933248.08719.826434.31992375.08.651471000Odyssey3.7988426375137.9248041215-1-11-1MMT/Spectra/Final/MMT/spHect-2014.0524_2.zlog4.0
1237662698115432544248.05133958719.695739699333525336013620825118.3917.226816.792316.586216.44820.03616210.006892680.006423010.008109590.02140180.2822990.2077130.1506510.1142340.080993319.503520.26867.5248123.17027590325.1619512.36616.813322.37279126029999.09999.09999.09999.09999.09999.014.50220.016604715.5560.1370.008224-1.0-10.0212260.008567248.08719.826434.31992375.08.651471000Odyssey8.0938844500480.8032315415-1-11-1MMT/Spectra/Final/MMT/spHect-2013.0510_5.zlog4.0
1237662224092496776248.19536859219.8670126788328169214099532819420.178219.03918.741718.524818.51860.1135630.02975640.05922490.1047940.1096410.3425840.252070.1828220.1386290.098289420.787521.6043.5110223.46429381153.099635.8039918.721423.17341350029999.09999.09999.09999.09999.09999.016.41740.068063717.089999.00.00824-1.0-10.0419190.019328248.08719.826434.31992375.08.651471000Odyssey6.5842099755965.7318019202-1-11-1MMT/Spectra/Final/MMT/spHect-2014.0524_1.zlog3.0
1237662698115433445248.1634268419.79220759436898804352030021.927220.754220.495221.037220.13340.3372070.05952090.06320880.1722840.2268260.3194940.235080.17050.1292850.091664621.750322.38251.2039623.34254580711.382534.0820420.823423.52220177939999.09999.09999.09999.09999.09999.020.36851.836379999.09999.00.007471-1.0-10.0395850.044217248.08719.826434.31992375.08.651471000Odyssey4.7767849240747.6878429659-1-11-1MMT/Spectra/Final/MMT/spHect-2013.0508.zlog4.0
1237662662147703369248.5807968519.720034902337216321614223796824222.76919.85519.447818.695320.70141.575060.1219090.06461170.05184381.106760.3424490.2519710.182750.1385740.098250621.47322.2945.2926425.06167777453.219345.3127219.787724.32197762439999.09999.09999.09999.09999.09999.016.6680.1144279999.09999.00.008178-1.0-10.1571620.103385248.08719.826434.31992375.08.651471000Odyssey28.5929254688285.447153061-1-11-1MMT/Spectra/Final/MMT/spHect-2013.0509_3.zlog4.0
1237662662147310256247.82589224120.2108787761314415044143598824023218.494217.498617.090816.827516.75620.06378830.01340110.01756350.02649010.07053780.326040.2398970.1739940.1319340.093542920.230921.0348-99.0-99.07.9587323.7301-99.023.13377443769999.09999.09999.09999.09999.09999.015.09880.0312699999.09999.00.0081454.25059e-0700.0453940.015723248.08719.826434.31992375.08.651471000Odyssey27.3735307895273.274029334147082-11-1AAT/Spectra/Final/AAT/Odyssey_1.zlog4.0

Are the objID-matches complete?


In [20]:
np.all(np.in1d(odysats['objID'], mltab['OBJID_1']))


Out[20]:
True

OK, all sats are represented, at least


In [22]:
np.sum(np.in1d(odycat['objID'], mltab['OBJID_1'])), np.sum(np.in1d(odycat['objID'], mltab['OBJID_2'])), len(odycat)


Out[22]:
(34354, 20972, 116533)

In [25]:
np.sum(np.in1d(mltab['OBJID_1'], odycat['objID'])), np.sum(np.in1d(mltab['OBJID_2'], odycat['objID']))


Out[25]:
(34337, 20955)

In [36]:
mlclosemsk = SkyCoord(mltab['RA'], mltab['DEC'], unit=u.deg).separation(ody.coords) < 2*u.deg
np.sum(np.in1d(mltab[mlclosemsk]['OBJID_1'], odycat['objID'])), np.sum(np.in1d(mltab[mlclosemsk]['OBJID_2'], odycat['objID'])), np.sum(mlclosemsk)


Out[36]:
(34337, 20955, 52841)

Lets just forge ahead assuming OBJID_1 is the thing to match against


In [52]:
mltab['objID'] = mltab['OBJID_1']
joinedcat = table.join(odycat, mltab)
joinedsats = table.join(odysats, mltab)
del mltab['objID']
joinedcat


Out[52]:
<Table masked=True length=34354>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDSATSREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEATOBJID_1RADECDERED_RPROBABILITY_CLASS_1BEST_GUESS_CLASSOBJID_2PROBABILITY_CLASS_WISE_1BEST_GUESS_CLASS_WISE
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string376float64float64int64int64int64string32string376float64string376int64float64float64float64float64int64int64float64int64
1237662223555166384247.1129300220.1256853311635253361705492018.195716.94716.477116.307416.24290.01245890.004990270.005305940.005405580.007498570.3338140.2456170.1781420.135080.095773316.796517.28260.0-33.52288818360.4825071.0632516.544116.95708606415.3950.04714.9520.05614.9330.10514.78990.012105715.0650.094-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey57.8381103188577.38531951-1-1-1-1.01237662223555166384247.1129300220.125685331116.2990.000229049863275012376622235551663840.0003218367952320
1237662223555166389247.09925545620.11939479896105553419960340022.381822.329120.064121.896520.45670.2210070.1121940.02375270.1515110.1385320.3346150.2462060.1785690.1354040.096002918.633419.37330.18101318.34805088170.4754950.93842520.201420.5825380179999.09999.09999.09999.09999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey58.4576886899583.56984309-1-1-1-1.01237662223555166389247.09925545620.119394798919.88550.06678635056890--nan--
1237662223555166535247.07136510620.0635458809635255507619856208745999367775232017.802917.410717.410717.245817.36490.01028570.005402870.00596010.00624080.01267360.343480.2527290.18330.1389910.098546417.728618.21650.017299410.59646949550.4983761.1049317.468817.951999672816.2540.08815.6470.10215.0020.11813.2190.002668512.0460.0250.5701365.64646e-050-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.0654167929589.636060941-1-1-1SDSSSDSS4.0SDSS1237662223555166535247.07136510620.063545880917.22740.000457855631498012376622235551665350.0001464875125740
1237662223555166681247.11722884820.1392443591634628174336022.049720.306119.170817.980217.26910.1465150.01946090.0114750.008001520.01245770.3336830.245520.1780720.1350270.095735519.524420.03440.31854418.68214091470.5549911.2405519.217919.934775882315.7750.06815.2430.07614.8730.10214.86210.012571114.8120.077-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey57.8662658986577.666364021-1-1-1-1.01237662223555166681247.11722884820.139244359118.99280.00011964491182012376622235551666815.27159388403e-050
1237662223555166763247.07913039820.1190341086368987912704021.462619.179918.120417.641617.3230.2145760.01672490.01010030.01003950.02513670.336320.2474610.1794790.1360940.096492119.377620.02291.4600421.27804279181.685814.4468818.291121.420646506516.7560.13716.0270.13915.6140.20114.69230.014967314.880.081-1.0-1.0-10.1296310.023243248.08719.826434.31992375.08.651471000Odyssey59.5356297471594.329618018-1-1-1-1.01237662223555166763247.07913039820.119034108617.94090.00053454982081012376622235551667630.0003110416336590
1237662223555166765247.0566229820.0720184169368987912192021.535219.70718.819518.426918.07560.1394310.0169290.01165430.01214330.02905220.3445360.2535060.1838640.1394180.098849519.518420.10430.62749919.99571657970.9661812.5367818.87920.79972751149999.09999.09999.09999.09999.09999.015.81170.033298415.9970.192-1.0-1.0-10.0752510.019545248.08719.826434.31992375.08.651471000Odyssey59.9961849353598.926762726-1-1-1-1.01237662223555166765247.0566229820.072018416918.63570.0012192907525012376622235551667650.0005465123960010
1237662223555166768247.07089270220.0850142414635255507615760023.228420.113318.609717.726717.23270.3340730.0166230.008757450.007245620.01173810.3405520.2505750.1817380.1378060.097706418.930819.41573.12061e-05-1.923646862460.487811.0820318.67519.111747851215.9780.06615.2780.07715.1440.13415.0420.01531214.9070.078-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.4146162561593.121690368-1-1-1-1.01237662223555166768247.07089270220.085014241418.4289.12105270782e-05012376622235551667685.30776518708e-050
1237662223555166777247.06868926420.067622614335253360132696020.769219.459818.584318.064117.67280.1224740.02239210.01488840.0148480.03610970.3433390.2526260.1832250.1389340.098506120.024720.6973.7091923.42616437932.195495.2827118.668322.371409151517.0290.17516.0790.15315.7170.21414.35950.011170414.5750.062-1.0-1.0-10.1315190.04184248.08719.826434.31992375.08.651471000Odyssey59.2712682627591.690824119-1-1-1-1.01237662223555166777247.06868926420.06762261418.40110.000127642358174012376622235551667770.0003478310001580
1237662223555166928247.09306404220.1563335076668987912192021.840121.192720.821120.623520.3570.1176750.03372330.03163510.03904610.1127220.3350060.2464940.1787780.1355620.096115121.134821.62540.041040515.88302543790.4762971.0533820.898321.28318644889999.09999.09999.09999.09999.09999.017.60490.1587519999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.4913997722593.888125099-1-1-1-1.01237662223555166928247.09306404220.156333507620.64230.0008142891685580--nan--
1237662223555166931247.08672860520.1459538015635253360001040022.027120.948720.642420.510620.45820.1346980.02827440.02785720.03569960.1224990.3349910.2464830.178770.1355560.096110920.986521.470.0006143856.580207942410.4437840.91945320.783121.01437924889999.09999.09999.09999.09999.09999.019.52720.944329999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.6255656467595.227336125-1-1-1-1.01237662223555166931247.08672860520.145953801520.46370.0005214359208020--nan--
..................................................................................................................................................................................................................
1237665232670950000247.51633065218.9882022455668987912192022.269720.681920.040619.715819.53720.2002490.02760.02002920.02330770.06875420.2448260.1801410.1306530.09907040.070242120.345520.81113.45896e-05-0.269221859370.6455331.2464220.117221.16227718239999.09999.09999.09999.09999.09999.017.76360.170139999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.7226253026596.196161366-1-1-1-1.01237665232670950000247.51633065218.988202245519.90990.006020711989740--nan--
1237665232670950004247.54398117818.9812852701668987912192022.168620.859420.164819.911119.66840.1871430.03169430.02206550.02729030.07861040.2405280.1769780.1283590.09733110.06900920.475520.94410.11617117.48578591910.6530921.2340820.257921.32825062589999.09999.09999.09999.09999.09999.018.32220.2813189999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.2503381187591.481904215-1-1-1-1.01237665232670950004247.54398117818.981285270120.03650.005628202939880--nan--
1237665232670950071247.48486695919.0108677076368987912960025.194822.775621.023120.185719.74650.7091090.1534990.04301990.03478480.08318970.2494150.1835170.1331020.1009270.071558621.341221.82870.25640720.06313923370.9710144.9717720.676322.60785735549999.09999.09999.09999.09999.09999.017.38480.1214199999.09999.0-1.0-1.0-10.4557490.04419248.08719.826434.31992375.08.651471000Odyssey59.5769706901594.74227323-1-1-1-1.01237665232670950071247.48486695919.010867707620.890.0001037083859870--nan--
1237665232670950162247.50967847618.99490497263439902697296200026.899819.466819.142719.196618.81945.19270.1460880.171220.2893790.7577870.2461490.1811140.1313590.09960570.070621723.394723.887959.348628.997868215923.451831.18118.914527.76086696459999.09999.09999.09999.09999.09999.020.32711.820259999.09999.0-1.0-1.0-10.0317430.03633248.08719.826434.31992375.08.651471000Odyssey59.5888571166594.860920624-1-1-1-1.01237665232670950162247.50967847618.994904972619.01140.1161950631540--nan--
1237665232670950180247.51874075518.9953315547668987912704023.048721.345120.879720.658420.45510.3933470.04721470.03872940.05157820.1571080.2447790.1801060.1306280.09905110.070228521.204621.69530.16130818.93082339851.22545.5841520.384222.82108455829999.09999.09999.09999.09999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.2891592372591.869407711-1-1-1-1.01237665232670950180247.51874075518.995331554720.74910.001356592868750--nan--
1237665232670950264247.54807254518.978890462668987912448024.085222.445921.011120.433619.88290.7592540.1178230.04370040.04312890.09853130.2398640.1764890.1280050.09706210.068818321.345221.83750.21019119.6275532810.6813131.2416121.135822.29800737369999.09999.09999.09999.09999.09999.018.43660.3194699999.09999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.2544726055591.523173716-1-1-1-1.01237665232670950264247.54807254518.97889046220.88310.0001849011909250--nan--
1237665232670950287247.54818205518.9657753968368987912448025.404921.406820.100719.550719.23621.057190.06579990.02997630.02930860.07944660.2391380.1759560.1276180.09676860.068610120.784621.40330.93614421.95291551651.189422.4609220.106722.47879741019999.09999.09999.09999.09999.09999.016.40030.052499916.0530.208-1.0-1.0-10.2027840.029253248.08719.826434.31992375.08.651471000Odyssey59.9279964779598.24612357-1-1-1-1.01237665232670950287247.54818205518.965775396819.97315.09135953466e-05012376652326709502874.68457242174e-050
1237665232670950416247.59836887318.9466054972368987912960025.203421.624420.442819.713919.26261.170650.08246250.04042010.03447990.08444170.235020.1729260.125420.09510240.067428821.202821.76770.81281722.21539387151.208043.2242520.475422.88124340839999.09999.09999.09999.09999.09999.017.46010.1478189999.09999.0-1.0-1.0-10.2920050.101261248.08719.826434.31992375.08.651471000Odyssey59.5583467835594.556373946-1-1-1-1.01237665232670950416247.59836887318.946605497220.31745.45109731191e-050--nan--
1237665232671015097247.62849203618.9301165361635253360132624020.651919.437918.875918.672518.55570.06047820.01202630.009936150.0113280.03254240.2360.1736460.1259430.09549860.067709719.199319.67220.11487616.17252640540.7017851.5235318.912920.13937915029999.09999.09999.09999.09999.09999.017.08640.094044516.7699999.0-1.0-1.0-1-1.0-1.0248.08719.826434.31992375.08.651471000Odyssey59.6802290418595.772972539-1-1-1-1.01237665232671015097247.62849203618.930116536118.750.000700753579481012376652326710150970.0009211982632830
1237665232671015571247.62185914618.9355459429368987912448457239258646760652823.240822.355320.739419.676619.38270.7403560.161170.05445340.03413150.09786050.2357470.173460.1258080.09539640.067637221.543422.09740.54821921.75287442651.49734.6062720.640223.51223805749999.09999.09999.09999.09999.09999.015.90530.03144116.8390.4940.6333580.00014616200.5213930.0343248.08719.826434.31992375.08.651471000Odyssey59.5509586274594.482627173-1-1-1SDSSSDSS4.0SDSS1237665232671015571247.62185914618.935545942920.61368.36098303076e-05012376652326710155716.46466554325e-050

In [344]:
def find_similar_objects(baseobj, catalog, propertytolerances):
    """
    minus sign on propertytolerances means *multiplicative* tolerance (>1).  Can also
    be a function that takes the base value and comparison vals and gives a mask
    """
    msk = np.ones(len(catalog), dtype=bool)
    
    for prop, tol in propertytolerances.items():
        if '-' in prop:
            m1, m2 = prop.split('-')
            compval = catalog[m1] - catalog[m2]
            baseval = baseobj[m1] - baseobj[m2]
        else:
            compval = catalog[prop]
            baseval = baseobj[prop]
            
        if callable(tol):
            msk = msk & tol(baseval, compval)
        elif tol >=0:
            msk = msk & (np.abs(compval - baseval) < tol)
        else:
            msk = msk & ((baseval/-tol)<compval) & (compval<(baseval*-tol))
    
    return catalog[msk]

def show_similar_objects(baseobj, catalog, propertytolerances, nameinfo=None, sorton=None):
    simcat = find_similar_objects(baseobj, catalog, propertytolerances)
    ras = np.insert(simcat['ra'], 0, baseobj['ra'])
    decs = np.insert(simcat['dec'], 0, baseobj['dec'])
    if nameinfo is None:
        nameinfos = []
    else:
        nameinfos = [nameinfo] if isinstance(nameinfo, basestring) else nameinfo
        
    names = []
    if sorton is not None:
        if sorton.startswith('-'):
            sorton = sorton[1:]
            reversesort = True
        else:
            reversesort = False
        sortvals = []
    enum = list(enumerate(simcat))
    enum.insert(0, (-1, baseobj))
    for i, row in enum:
        pieces = ['Realobj'] if i==-1 else ['Fakeobj' + str(i)]
        for nameinfo in nameinfos:
            label = 'p' if nameinfo.startswith('PROBABILITY') else nameinfo
            pieces.append('{}={:.3f}'.format(label, row[nameinfo]))
        names.append('_'.join(pieces))
        if sorton is not None:
            sortvals.append(row[sorton])
            
    if sortvals:
        sorti = np.argsort(sortvals)
        if reversesort:
            sorti = sorti[::-1]
        ras = ras[sorti]
        decs = decs[sorti]
        names = np.array(names)[sorti]

    targeting.sampled_imagelist(ras, decs, names=names, n=np.inf, posttoimglist=0.5)
    return simcat

In [346]:
tols = {'r':1, 'g-r':.2, 'petroR50_r':-3.5, 
               'spec_z':lambda objval, catval:(np.abs(catval-objval)/objval > .5) & (catval>-1),
               }#'PROBABILITY_CLASS_1': lambda objval, catval: catval <  (objval*.5)}

nonsatcats = []
for sat in joinedsats:
    nonsatcats.append(show_similar_objects(sat, joinedcat, tols, ['spec_z', 'PROBABILITY_CLASS_1'], 
                                           sorton='-PROBABILITY_CLASS_1'))

In [347]:
realsats_idxs = [2, 5, 7]
nonsat_idxs = [[1, 14], [12, 11], [1, 33]]

In [350]:
#convert those to rows
realsats_rows = joinedsats[np.array(realsats_idxs)]
nonsat_rows = [[nonsatcats[ri][li] for li in lis] for ri, lis in zip(realsats_idxs, nonsat_idxs)]

In [351]:
def row_to_cutout_img(row, size=(400, 400), scale=0.1):
    baseurl = 'http://skyservice.pha.jhu.edu/DR12/ImgCutout/getjpeg.aspx'
    res = requests.get(baseurl, dict(ra=row['ra'], dec=row['dec'], scale=scale, width=size[0], height=size[1]))
    sio = StringIO(res.content)
    sio.seek(0)
    return mpimg.imread(sio, 'jpeg')

In [359]:
fig, spls = plt.subplots(len(nonsat_idxs[0])+1, len(realsats_idxs), figsize=(10, 10))

for ax, row in zip(spls[0], realsats_rows):
    imdata = row_to_cutout_img(row)
    ax.imshow(imdata)
    ax.set_xticks([])
    ax.set_yticks([])

for imcol in range(len(nonsat_idxs[0])+1):
    for ax, row in zip(spls[1:, imcol], nonsat_rows[imcol]):
        imdata = row_to_cutout_img(row)
        ax.imshow(imdata)
        ax.set_xticks([])
        ax.set_yticks([])
        
spls[0, 0].set_ylabel('Real Satellites', fontsize=20)
for spl in spls[1:, 0]:
    spl.set_ylabel('Non-Satellites', fontsize=20)
fig.tight_layout()
plt.savefig('satnonsatcomp2.png')
plt.savefig('satnonsatcomp2.pdf')



In [360]:
print 'Real sats:'
for row in realsats_rows:
    print row['ra'], row['dec'], row['spec_z'],  row['PROBABILITY_CLASS_1']


Real sats:
247.825892241 20.2108787761 0.008145 0.459613790263
248.051339587 19.6957396993 0.008224 0.525459360418
248.16342684 19.792207594 0.007471 0.0140341939762

In [365]:
print 'Non-sats:'
for i,rows in enumerate(nonsat_rows):
    print 'For realsat #', i+1
    for row in rows:
        print row['ra'], row['dec'], row['spec_z'],  row['PROBABILITY_CLASS_1']


Non-sats:
For realsat # 1
248.282242282 20.7635522393 0.0358905 0.0245511012197
247.430414803 19.3932699725 0.0352353 0.0633943760791
For realsat # 2
247.586344578 20.5748995768 0.0369235 0.163668118206
247.827149304 19.9813131712 0.0633817 0.00217939800516
For realsat # 3
248.139305346 19.3855129623 0.215105 0.00238110292132
247.082860086 19.7554252371 2.72519 0.00057479534986

Older version


In [295]:
fig, spls = plt.subplots(len(lowprob_idxs[0])+1, len(realsats_idxs), figsize=(7, 12))

for ax, row in zip(spls[0], realsats_rows):
    imdata = row_to_cutout_img(row)
    ax.imshow(imdata)
    ax.set_xticks([])
    ax.set_yticks([])

for imcol in [0, 1]:
    for ax, row in zip(spls[2:, imcol], lowprob_rows[imcol]):
        imdata = row_to_cutout_img(row)
        ax.imshow(imdata)
        ax.set_xticks([])
        ax.set_yticks([])
        
spls[0, 0].set_ylabel('Real\nSatellites', fontsize=20)
spls[1, 0].set_ylabel('High-Prob\nNon-Satellites', fontsize=20)
fig.tight_layout()
spls[3, 0].set_ylabel('{0}Low-Prob\n{0}Non-Satellites'.format(' '*36), fontsize=20)
plt.savefig('satnonsatcomp.png')
plt.savefig('satnonsatcomp.pdf')


Check 150887 targets


In [11]:
cat150887 = Table.read('catalogs/base_sql_nsa150887.fits.gz')

In [15]:
allspec5 = Table.read(os.environ['HOME']+'/Dropbox/SAGA/data/allspectaken_v5.fits.gz')
allspecin150887 = allspec5[allspec5['HOST_NSAID']==150887]

In [17]:
mltab['objID'] = mltab['OBJID_1']
joinedcat = table.join(cat150887, mltab)
joinedspec = table.join(allspecin150887, mltab)
del mltab['objID']

In [23]:
goodspec =  joinedspec[joinedspec['ZQUALITY']>3]
goodspec


Out[23]:
<Table masked=True length=757>
objIDradecphot_sgflagsspecObjIDugrizu_errg_errr_erri_errz_errAuAgArAiAzfibermag_rfiber2mag_rexpRad_rsb_exp_rpetroR50_rpetroR90_rpetroMag_rsb_petro_rJJerrHHerrKKerrw1w1errw2w2errspec_zspec_z_errspec_z_warnphotozphotoz_errHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_NSAIDHOST_FLAGHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDSATSPCLASS_1PCLASS_1_WISEREMOVETELNAMEMASKNAMEZQUALITYSPEC_REPEATOBJID_1RADECDERED_RPROBABILITY_CLASS_1BEST_GUESS_CLASSOBJID_2PROBABILITY_CLASS_WISE_1BEST_GUESS_CLASS_WISE
int64float64float64int16int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float32float32float32float64float32float32float32float32float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64int64int64string384float64float64int64int64float64float64int64string32string384float64string384int64float64float64float64float64int64int64float64int64
1237678598622216655348.2400201723.64578198581368987912448482680885892664524825.637621.769319.772619.039518.61171.314140.09280170.02617030.0214680.05241640.2661980.1958660.1420580.1077190.076373820.528721.16731.0254121.82257360891.316193.2201819.729622.32168174359999.09999.09999.09999.09999.09999.015.06550.020297614.9790.110.3903988.7297e-0500.4021020.025838348.6834.5340637.0192689.08.3271508870Catch2259.5193551281640.89564418-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622216655348.2400201723.6457819858119.63066.24224326597e-05012376785986222166556.22064674122e-050
1237678598622281801348.4452076773.617929425423105622104310032482679703917664665622.626421.568620.371419.552319.87990.9165190.1159390.061650.04637480.2228960.2889930.2126390.1542230.1169430.082913921.392222.0270.97430322.86629173172.088145.2892220.378123.9723185779999.09999.09999.09999.09999.09999.016.63330.078239999.09999.00.4795026.80017e-0500.4494220.167992348.6834.5340637.0192689.08.3271508870Catch2256.77810677611.381034633-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622281801348.4452076773.6179294254220.21720.0001616402745210--nan--
1237678598622347750348.5007353893.64274377779368987912960482678494454874112027.045122.630720.852119.646919.14390.3497850.1665810.05553840.03006950.06742840.2990150.2200120.1595710.1209980.085789221.468922.02780.60621921.88767205891.033212.9928820.892322.95875177179999.09999.09999.09999.09999.09999.015.13510.019920914.9350.0970.6049510.00019808800.582260.024144348.6834.5340637.0192689.08.3271508870Catch2254.5788111583587.701266997-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622347750348.5007353893.6427437777920.69263.13684897121e-05012376785986223477502.12843560056e-050
1237678598622347857348.5521498173.622972183893105624251662608482678631893827584023.178822.860721.130720.149519.80970.6874960.1722330.05953710.03751990.09922740.2984380.2195880.1592630.1207650.085623721.050521.72230.48801621.56831390140.884062.2142921.077322.80520802549999.09999.09999.09999.09999.09999.015.92290.040739115.3470.1320.4503230.00014770900.5422590.066498348.6834.5340637.0192689.08.3271508870Catch2255.2226838917594.633855935-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622347857348.5521498173.6229721838920.97140.000396184969188012376785986223478570.0002362299214720
1237678598622347904348.5707184933.63177685833372163216142242064482678659381618278426.695521.772320.065519.187418.78730.9178530.1489540.0512510.03630140.09160710.3013220.221710.1608030.1219320.086451221.389822.01521.2737623.02681564532.127875.8426920.141823.77699819389999.09999.09999.09999.09999.09999.016.01980.044855216.090.2630.4496940.00022411800.470550.01569348.6834.5340637.0192689.08.3271508870Catch2254.5519531584587.412085994-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622347904348.5707184933.6317768583319.90472.81913532832e-05012376785986223479045.0054370073e-050
1237678598622413249348.689484063.543047305733160745862070528482677284992083558425.240322.230720.602219.647319.17941.642990.1453060.05332430.03547110.08453080.3057780.2249890.163180.1237350.087729521.389522.01971.1503922.90190284351.314392.8553220.585223.17431187949999.09999.09999.09999.09999.09999.015.62060.033110915.5630.1630.4870970.00016598900.5047060.022007348.6834.5340637.0192689.08.3271508870Catch2259.4620264183640.278398675-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622413249348.689484063.5430473057320.4391.9453675155e-05012376785986224132492.37256738832e-050
1237678598622413376348.7427333973.60034738969379792571208482677312479874252824.367720.947619.159818.547918.04622.171960.05612210.01871960.01685160.03719180.3337160.2455450.178090.135040.09574520.137320.74220.94659421.33227718181.402534.1963719.248821.9787723459999.09999.09999.09999.09999.09999.014.93740.019160814.7990.0890.3366357.15312e-0500.3548960.022388348.6834.5340637.0192689.08.3271508870Catch2256.1365662588604.473607431-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622413376348.7427333973.6003473896918.98173.25138404247e-05012376785986224133763.09408181487e-050
1237678598622478350348.7859392913.60137694125335219001446748482677339967664947225.538721.902920.775519.755219.37991.213970.09911840.05382840.03451090.08760790.3500970.2575980.1868320.1416690.10044521.402222.01370.89646922.53366000961.041561.9312220.868722.95259092089999.09999.09999.09999.09999.09999.015.45370.027892715.6970.20.5259910.00017122500.5810780.127579348.6834.5340637.0192689.08.3271508870Catch2256.2986738655606.219012053-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622478350348.7859392913.6013769412520.58874.67536604197e-05012376785986224783507.44097180339e-050
1237678598622478636348.8685412473.65754725459335253360132112482676212968246476821.978919.787418.177317.639117.29470.4738810.02578440.01046650.009970580.02391480.3700020.2722440.1974540.1497230.10615619.373519.99631.1888420.88190695011.889395.5281918.223721.600712465216.7840.14315.9660.15615.2760.13514.20560.010784114.2480.0620.2981275.13059e-0500.2505030.015309348.6834.5340637.0192689.08.3271508870Catch2253.7489168002578.765749606-103.41929153495e-054.1757325018e-05-1SDSSSDSS4.0SDSS1237678598622478636348.8685412473.6575472545917.97993.41929153495e-05012376785986224786364.1757325018e-050
1237678598622544476349.0081268653.63422212346335219000394072482675415822316339222.120420.648319.053418.343617.85430.7292830.06770120.02596770.0213230.04998580.3634820.2674460.1939740.1470850.10428520.614421.26991.8816222.7987600422.108624.5772919.33122.946460936617.2140.21316.0880.17215.7520.19814.90630.022969815.1540.1180.2659317.97354e-0500.3447620.059282348.6834.5340637.0192689.08.3271508870Catch2257.3856981655617.922914166-10-1.0-1.0-1SDSSSDSS4.0SDSS1237678598622544476349.0081268653.6342221234618.85949.09149127123e-05012376785986225444760.0001079223735420
........................................................................................................................................................................................................................
1237679006095770369349.1221282855.42727825688335253360136464496414748867349708824.708921.350819.707918.861718.44761.460670.06602480.02619690.02092840.04739540.405130.2980910.21620.1639380.11623420.547721.14920.74307821.23734319741.171482.7750319.822722.16180660149999.09999.09999.09999.09999.09999.014.94330.017628914.8720.0840.459217.77802e-0500.4312780.029468348.6834.5340637.0192689.08.3271508870Catch2259.6831872168642.659586965-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095770369349.1221282855.4272782568819.49174.12616184996e-05012376790060957703696.93522727813e-050
1237679006095770475349.0540465825.412586473883105624251794264496415463549907763223.749222.826721.175920.011419.65141.177940.2554410.09778160.06015850.1493010.4335430.3189970.2313630.1754360.12438622.163322.75330.7841823.05387924711.656743.8882421.178524.27019347769999.09999.09999.09999.09999.09999.015.69670.032012415.5710.1570.5579690.00032001200.572410.038146348.6834.5340637.0192689.08.3271508870Catch2257.1930616688615.848817166-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095770475349.0540465825.4125864738820.94457.50353418668e-05012376790060957704750.0001210492389420
1237679006095770515349.0883216335.35617389587368987912960496414556452814848025.404922.106220.384119.413519.06412.431790.2582140.09264590.06587150.1682870.4069780.299450.2171860.1646860.11676422.071722.70332.2475124.64554554283.863749.5270120.38425.31447909549999.09999.09999.09999.09999.09999.015.7660.033794515.8060.1870.5869850.00028116600.4978410.017411348.6834.5340637.0192689.08.3271508870Catch2254.9624312107591.831713282-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095770515349.0883216335.3561738958720.16694.32145973708e-05012376790060957705152.39782092017e-050
1237679006095835143349.1415948855.237796778123105622104310032496414528965024153623.719421.981620.202119.367918.95431.060110.1086050.03739080.02927730.07024650.3820240.281090.203870.1545880.10960520.992521.62271.4765823.04382085261.698415.1127119.948723.09438371229999.09999.09999.09999.09999.09999.015.39140.028765215.2170.1160.3783210.00015632600.4568690.037906348.6834.5340637.0192689.08.3271508870Catch2250.3514216765542.184389968-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095835143349.1415948855.2377967781219.99823.6595023312e-05012376790060958351432.50622159631e-050
1237679006095835286349.1705866995.38011335966335253360132112496413346990024294420.288318.342217.187316.690516.31280.09951180.009947060.006203420.006298330.01307150.3811590.2804530.2034080.1542380.10935718.584819.21141.4579120.39531810332.432917.6145717.237221.163268827315.9010.08215.1930.09514.7320.10713.61670.0067060113.8880.0490.1435882.17467e-0500.1502660.00982348.6834.5340637.0192689.08.3271508870Catch2258.5441800212630.396125927-100.0007598424328645.1309716843e-05-1SDSSSDSS4.0SDSS1237679006095835286349.1705866995.3801133596616.98390.000759842432864012376790060958352865.1309716843e-050
1237679006095835643349.1770091125.26491523419335253360132368496413292014442905627.255720.986219.212718.58618.08220.44480.08175750.02836310.02644570.05838680.3788240.2787350.2021620.1532930.10868720.700121.3551.3042722.25141137022.000275.434219.447722.94863806349999.09999.09999.09999.09999.09999.014.83520.021466514.9880.0920.3805760.00011742300.3429760.025858348.6834.5340637.0192689.08.3271508870Catch2252.8773058105569.381030686-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095835643349.1770091125.2649152341919.01063.56753169507e-05012376790060958356435.20869850925e-050
1237679006095835870349.2564174995.23358782396368987912704496413319502233600022.962121.807620.081319.260618.71310.7084160.1122150.03949320.03118180.06658370.3777890.2779740.201610.1528750.1083921.100921.69850.77563521.9026988271.639525.8192220.052623.12166390639999.09999.09999.09999.09999.09999.015.06720.021140915.0790.1070.4562260.00016120900.4349320.030976348.6834.5340637.0192689.08.3271508870Catch2254.2026872537583.651524807-109.52678432582e-056.56645946987e-05-1SDSSSDSS4.0SDSS1237679006095835870349.2564174995.2335878239619.87979.52678432582e-05012376790060958358706.56645946987e-050
1237679006095835912349.2751560215.24908158021335287719739408496413237038861516826.354820.860219.085718.394118.0040.8844170.06617040.02297560.02052990.0486120.3793870.2791490.2024620.1535210.10884820.417321.06531.2194521.91157649691.684264.3746819.337122.464644114717.0949999.016.2430.21615.4630.18614.65540.015529514.8680.0910.3600626.41277e-0500.3611790.022432348.6834.5340637.0192689.08.3271508870Catch2255.6324370648599.045664644-103.93691235722e-054.90225798654e-05-1SDSSSDSS4.0SDSS1237679006095835912349.2751560215.2490815802118.88323.93691235722e-05012376790060958359124.90225798654e-050
1237679006095901128349.3015567385.28878093843335253360136464496413484428977766423.729621.562419.636318.780218.36431.741580.1328530.03756770.02965750.06925710.3867760.2845860.2064050.1565110.11096820.946121.59861.2116922.57044413942.873628.6929619.552523.84012904639999.09999.09999.09999.09999.09999.014.50190.014980614.4060.0630.4548470.00012914700.4524770.012838348.6834.5340637.0192689.08.3271508870Catch2258.475383199629.65540217-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095901128349.3015567385.2887809384319.42996.87702174113e-05012376790060959011285.21897271861e-050
1237679006095901206349.330592645.2667419354368987912448496412165015024435223.177721.910520.050519.188118.63270.6664280.101330.0315140.02475390.04974760.3949350.2905890.2107590.1598130.11330920.83121.41240.61196321.2295338851.226533.6038220.027122.46589598229999.09999.09999.09999.09999.09999.015.16940.02176215.2920.1250.4628530.00012373800.4616650.015241348.6834.5340637.0192689.08.3271508870Catch2258.590800031630.898075549-10-1.0-1.0-1SDSSSDSS4.0SDSS1237679006095901206349.330592645.266741935419.83973.28064431568e-05012376790060959012060.0001598330891050

In [34]:
dict([(utn, np.sum(utn==goodspec['TELNAME'])) for utn in np.unique(goodspec['TELNAME'])])


Out[34]:
{'MMT': 188, 'NSA': 9, 'SDSS': 560}

In [41]:
bins = np.linspace(0,1,101)
for utn in np.unique(goodspec['TELNAME']):
    plt.hist(goodspec['PROBABILITY_CLASS_1'][utn==goodspec['TELNAME']], histtype='step', label=utn, bins=bins, log=True)
plt.legend(loc=0)


Out[41]:
<matplotlib.legend.Legend at 0x134837310>

In [43]:
np.sum(joinedcat['PROBABILITY_CLASS_1']>0.01), np.sum(joinedspec['PROBABILITY_CLASS_1']>0.01)


Out[43]:
(299, 27)